package com.wuzf.springcloud.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.wuzf.common.entity.CommonResult;
import org.springframework.stereotype.Component;


@Component
public class HystrixFallbackService implements HystrixService {


    @Override
    public CommonResult ok() {
        return new CommonResult(100, "（单独）错误了，哭唧唧");
    }

    @Override
    public CommonResult error() {
        return new CommonResult(100, "（单独）错误了，哭唧唧");
    }


    @Override
    @HystrixCommand(fallbackMethod = "default_fallback", commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "3000")
    })
    public CommonResult timeout() {
        return new CommonResult(100, "（单独）错误了，哭唧唧/通过feign配置的公共hystrix");
    }

    @Override
    public String paymentInfo_TimeOut(Integer id) {
        return "error 超时了";
    }

    public CommonResult default_fallback() {

        return new CommonResult(100, "（单独）错误了，哭唧唧/单独再controller中配置的hystrix");
    }
}
